<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>EOS.IO: Message C API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Message C API<div class="ingroups"><a class="el" href="group__contractdev.html">How To Write Contracts</a> &raquo; <a class="el" href="group__messageapi.html">Message API</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Define API for querying message properties.  
<a href="#details">More...</a></p>
<div class="dynheader">
Collaboration diagram for Message C API:</div>
<div class="dyncontent">
<center><table><tr><td><img src="group__messagecapi.png" border="0" alt="" usemap="#group____messagecapi"/>
<map name="group____messagecapi" id="group____messagecapi">
<area shape="rect" id="node2" href="group__messageapi.html" title="Define API for querying message properties. " alt="" coords="5,5,107,32"/>
</map>
</td></tr></table></center>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga95a7d555722669cdeb72d6d6d1236893"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__messagecapi.html#ga95a7d555722669cdeb72d6d6d1236893">readMessage</a> (void *msg, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> len)</td></tr>
<tr class="memdesc:ga95a7d555722669cdeb72d6d6d1236893"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy current message to the specified location.  <a href="#ga95a7d555722669cdeb72d6d6d1236893">More...</a><br /></td></tr>
<tr class="separator:ga95a7d555722669cdeb72d6d6d1236893"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa4e5f3cd4b54bccaa36e755caecda727"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__messagecapi.html#gaa4e5f3cd4b54bccaa36e755caecda727">messageSize</a> ()</td></tr>
<tr class="memdesc:gaa4e5f3cd4b54bccaa36e755caecda727"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the length of current message's data field.  <a href="#gaa4e5f3cd4b54bccaa36e755caecda727">More...</a><br /></td></tr>
<tr class="separator:gaa4e5f3cd4b54bccaa36e755caecda727"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaeb32e8229c58b2b2b045080dc1d4b850"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__messagecapi.html#gaeb32e8229c58b2b2b045080dc1d4b850">requireNotice</a> (<a class="el" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a> name)</td></tr>
<tr class="memdesc:gaeb32e8229c58b2b2b045080dc1d4b850"><td class="mdescLeft">&#160;</td><td class="mdescRight">Add the specified account to set of accounts to be notified.  <a href="#gaeb32e8229c58b2b2b045080dc1d4b850">More...</a><br /></td></tr>
<tr class="separator:gaeb32e8229c58b2b2b045080dc1d4b850"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaed0ef9b019ed08c7cc0241c5b4169f13"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__messagecapi.html#gaed0ef9b019ed08c7cc0241c5b4169f13">requireAuth</a> (<a class="el" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a> name)</td></tr>
<tr class="memdesc:gaed0ef9b019ed08c7cc0241c5b4169f13"><td class="mdescLeft">&#160;</td><td class="mdescRight">Verify specified account exists in the set of provided auths.  <a href="#gaed0ef9b019ed08c7cc0241c5b4169f13">More...</a><br /></td></tr>
<tr class="separator:gaed0ef9b019ed08c7cc0241c5b4169f13"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1f06c06adc584456cf30e8086d6b55b1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__messagecapi.html#ga1f06c06adc584456cf30e8086d6b55b1">currentCode</a> ()</td></tr>
<tr class="memdesc:ga1f06c06adc584456cf30e8086d6b55b1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the account which specifies the code that is being run.  <a href="#ga1f06c06adc584456cf30e8086d6b55b1">More...</a><br /></td></tr>
<tr class="separator:ga1f06c06adc584456cf30e8086d6b55b1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>A EOS.IO message has the following abstract structure:</p>
<div class="fragment"><div class="line"><span class="keyword">struct </span>Message {</div><div class="line">  <a class="code" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a> code; <span class="comment">// the contract defining the primary code to execute for code/type</span></div><div class="line">  <a class="code" href="group__types.html#ga4c11ea58b1daa61a364225a757a05cd2">FuncName</a> type; <span class="comment">// the action to be taken</span></div><div class="line">  AccountPermission[] authorization; <span class="comment">// the accounts and permission levels provided</span></div><div class="line">  Bytes data; <span class="comment">// opaque data processed by code</span></div><div class="line">};</div></div><!-- fragment --><p>This API enables your contract to inspect the fields on the current message and act accordingly.</p>
<p>Example: </p><div class="fragment"><div class="line"><span class="comment">// Assume this message is used for the following examples:</span></div><div class="line"><span class="comment">// {</span></div><div class="line"><span class="comment">//  &quot;code&quot;: &quot;eos&quot;,</span></div><div class="line"><span class="comment">//  &quot;type&quot;: &quot;transfer&quot;,</span></div><div class="line"><span class="comment">//  &quot;authorization&quot;: [{ &quot;account&quot;: &quot;inita&quot;, &quot;permission&quot;: &quot;active&quot; }],</span></div><div class="line"><span class="comment">//  &quot;data&quot;: {</span></div><div class="line"><span class="comment">//    &quot;from&quot;: &quot;inita&quot;,</span></div><div class="line"><span class="comment">//    &quot;to&quot;: &quot;initb&quot;,</span></div><div class="line"><span class="comment">//    &quot;amount&quot;: 1000</span></div><div class="line"><span class="comment">//  }</span></div><div class="line"><span class="comment">// }</span></div><div class="line"></div><div class="line"><span class="keywordtype">char</span> buffer[128];</div><div class="line"><a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> total = <a class="code" href="group__messagecapi.html#ga95a7d555722669cdeb72d6d6d1236893">readMessage</a>(buffer, 5); <span class="comment">// buffer contains the content of the message up to 5 bytes</span></div><div class="line"><a class="code" href="namespaceeos.html#a1df73defa04d39763089df7faa35a934">print</a>(total); <span class="comment">// Output: 5</span></div><div class="line"></div><div class="line"><a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> msgsize = <a class="code" href="group__messagecapi.html#gaa4e5f3cd4b54bccaa36e755caecda727">messageSize</a>();</div><div class="line"><a class="code" href="namespaceeos.html#a1df73defa04d39763089df7faa35a934">print</a>(msgsize); <span class="comment">// Output: size of the above message&#39;s data field</span></div><div class="line"></div><div class="line"><a class="code" href="group__messagecapi.html#gaeb32e8229c58b2b2b045080dc1d4b850">requireNotice</a>(<a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(initc)); <span class="comment">// initc account will be notified for this message</span></div><div class="line"></div><div class="line"><a class="code" href="group__messagecapi.html#gaed0ef9b019ed08c7cc0241c5b4169f13">requireAuth</a>(<a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(inita)); <span class="comment">// Do nothing since inita exists in the auth list</span></div><div class="line"><a class="code" href="group__messagecapi.html#gaed0ef9b019ed08c7cc0241c5b4169f13">requireAuth</a>(<a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(initb)); <span class="comment">// Throws an exception</span></div><div class="line"></div><div class="line"><a class="code" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a> code = <a class="code" href="group__messagecapi.html#ga1f06c06adc584456cf30e8086d6b55b1">currentCode</a>();</div><div class="line"><a class="code" href="namespaceeos.html#a1df73defa04d39763089df7faa35a934">print</a>(Name(code)); <span class="comment">// Output: eos</span></div><div class="line"></div><div class="line"><a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>(Name(<a class="code" href="group__messagecapi.html#ga1f06c06adc584456cf30e8086d6b55b1">currentCode</a>()) === <span class="stringliteral">&quot;eos&quot;</span>, <span class="stringliteral">&quot;This message expects to be received by eos&quot;</span>); <span class="comment">// Do nothing</span></div><div class="line"><a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>(Name(<a class="code" href="group__messagecapi.html#ga1f06c06adc584456cf30e8086d6b55b1">currentCode</a>()) === <span class="stringliteral">&quot;inita&quot;</span>, <span class="stringliteral">&quot;This message expects to be received by inita&quot;</span>); <span class="comment">// Throws exception and roll back transfer transaction</span></div><div class="line"></div><div class="line"><a class="code" href="namespaceeos.html#a1df73defa04d39763089df7faa35a934">print</a>(<a class="code" href="group__systemcapi.html#ga34bcb797186fc81170ac182f8bba1e7d">now</a>()); <span class="comment">// Output: timestamp of last accepted block</span></div></div><!-- fragment --> <h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga1f06c06adc584456cf30e8086d6b55b1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a> currentCode </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Get the account which specifies the code that is being run </p><dl class="section return"><dt>Returns</dt><dd>the account which specifies the code that is being run </dd></dl>

</div>
</div>
<a class="anchor" id="gaa4e5f3cd4b54bccaa36e755caecda727"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> messageSize </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Get the length of the current message's data field This method is useful for dynamically sized messages </p><dl class="section return"><dt>Returns</dt><dd>the length of the current message's data field </dd></dl>

</div>
</div>
<a class="anchor" id="ga95a7d555722669cdeb72d6d6d1236893"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> readMessage </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Copy up to len bytes of current message to the specified location </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">msg</td><td>- a pointer where up to len bytes of the current message will be copied </td></tr>
    <tr><td class="paramname">len</td><td>- len of the current message to be copied </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the number of bytes copied to msg </dd></dl>

</div>
</div>
<a class="anchor" id="gaed0ef9b019ed08c7cc0241c5b4169f13"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void requireAuth </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a>&#160;</td>
          <td class="paramname"><em>name</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Verifies that name exists in the set of provided auths on a message. Throws if not found </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>- name of the account to be verified </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaeb32e8229c58b2b2b045080dc1d4b850"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void requireNotice </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types.html#gad67b43dc23285b01176f4c181c59fc23">AccountName</a>&#160;</td>
          <td class="paramname"><em>name</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Add the specified account to set of accounts to be notified </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>- name of the account to be verified </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
